import Vue from 'vue'
import whMap from './index.vue'

const WHMap = function (options, callback) {
  let Task = Vue.extend(whMap)
  let taskvm = new Task()
  let preNode = document.getElementById(options.container)
  // let preNode = options.container
  preNode.appendChild(taskvm.$mount().$el)
  //  加载地图
  taskvm.loadMap(options).then(res => {
    callback(res)
  })
  console.log(taskvm);
  taskvm.onClickMarker = (e, data) => {
    this.onClickMarker(e, data)
  }
  taskvm.onClickPolygon = (e, data) => {
    this.onClickPolygon(e, data)
  }
  taskvm.onClickMap = (e) => {
    this.onClickMap(e)
  }
  // 加载图标
  this.loadMarker = function (list) {
    taskvm.loadMarker(list)
  }
  // 加载多边形
  this.loadPolygon = function (list) {
    taskvm.loadPolygon(list)
  }
  // 加载路径
  this.loadPath = function (config) {
    taskvm.loadPath(config)
  }

}

export default WHMap
